/*
if regexm(c(os),"Mac") == 1 {
	local mypath = "/Users/youruser"
	}
else if regexm(c(os),"Windows") == 1 local mypath = "c:/users/youruse"
*/


//  program:    200922_embedded_liberalism_digital_era_manscript.do
//  task:       figures for the IO paper
//  project:    mansfield & rudra


//  #0
//  setup
version 16
set linesize 80
clear all
macro drop _all
set more off




//  #1
//  GVC (fig 1)
use mansfield_rudra_embedded_liberalism_fig1.dta

graph hbar (sum) DVAco10_inB FVAco10_inB if inlist(year , 1990 , 2018)  ///
	, over(year, label(labsize(vsmall))) stack ///
	ylabel(0(2500)20000 , labsize(vsmall) angle(315)) ///
	bar(1,color(gs10)) bar(2,color(gs6)) ///
	graphregion(color(white)) ///
	legend(label(1 "Domestic value added") label(2 "Foreign value added") size(vsmall)) ///
	ytitle("DVA/FVA trade shares, world" ///
	"(billion of constant dollars, base = 2010)" , size(small)) 
		



//  #2
//  GVC (fig 2)
//  #2 - (a) : 1990
use mansfield_rudra_embedded_liberalism_fig2a.dta , clear
	
graph hbar (sum) dvaco10_ fvaco10_ ///
	, over(dev, sort(va_expco10_inB) label(labsize(vsmall))) stack ///
	ylabel(0(1000)15000 , labsize(vsmall) angle(315)) ///
	bar(1,color(gs10)) bar(2,color(gs6)) ///
	graphregion(color(white)) ///
	legend(label(1 "Domestic value added") label(2 "Foreign value added") size(vsmall)) ///
	ytitle("Domestic value added trade shares, 1990 (billion of constant dollars, base = 2010)" , size(small))
	

//  #2 - (b) : 2018
use mansfield_rudra_embedded_liberalism_fig2b.dta  , clear

graph hbar (sum) dvaco10_ fvaco10_ ///
	, over(dev, sort(va_expco10_inB) label(labsize(vsmall))) stack ///
	ylabel(0(1000)15000 , labsize(vsmall) angle(315)) ///
	bar(1,color(gs10)) bar(2,color(gs6)) ///
	graphregion(color(white)) ///
	legend(label(1 "Domestic value added") label(2 "Foreign value added") size(vsmall)) ///
	ytitle("Domestic value added trade shares, 2018 (billion of constant dollars, base = 2010)" , size(small))
	


	

//  #3
//  Fig 3
use mansfield_rudra_embedded_liberalism_fig3.dta , clear

graph twoway connect fdi_netinflow year ///
	, graphregion(color(white)) ///
	lcolor(gs7) ///
	mcolor(gs7) ///
	msize(vsmall) ///
	ytitle( , size(small)) ylabel(, labsize(small) angle(360)) ///
	xtitle("Year" , size(small)) xlabel(1970(5)2015 2018 , labsize(small)) 




	
//  #4
//  Fig 4
use mansfield_rudra_embedded_liberalism_fig4.dta , clear

graph twoway connect emp_affiliate_pct_lbr year if year >= 1996 ///
	, graphregion(color(white)) ///
	lcolor(gs7) ///
	mcolor(gs7) ///
	msize(vsmall) ///
	ytitle("% of affiliate employees out of world labor force" , size(small)) ylabel(, labsize(small) angle(360)) ///
	xtitle("Year" , size(small)) xlabel(1996(5)2018 , labsize(small)) 





//  #5
//  Fig 5
use mansfield_rudra_embedded_liberalism_fig5.dta , clear

graph twoway connect intra_trade year ///
	, graphregion(color(white)) ///
	lcolor(gs7) ///
	mcolor(gs7) ///
	msize(vsmall) ///
	ylabel(28(1)34) ///
	ytitle("Related party trade % total, average of selected countries" , size(small)) ylabel(, labsize(small) angle(360)) ///
	xtitle("Year" , size(small)) xlabel(2005(1)2016 , labsize(small)) 




//  #6
//  Fig 6
use mansfield_rudra_embedded_liberalism_fig6.dta , clear

graph bar (mean) gini ///
	, over(time,  label(labsize(small))) over(group,  label(labsize(small)))  ///
	blabel(bar , position(outside) format(%12.2f) size(vsmall)) ///
	exclude0 ylabel(40(2)48 , labsize(vsmall) angle(360)) ///
	bar(1,color(gs6)) ///
	graphregion(color(white)) ///
	ytitle("Average GINI (gross income) coefficient" , size(small)) 



clear
exit